import Vue from 'vue'
import VueRouter from 'vue-router'
import Cart from '@/views/cart'
import Home from '@/views/home'
import List from '@/views/list'
import Detail from '@/views/detail'
import Login from '@/views/login'
import Category from '@/views/category'
import Mine from '@/views/mine'
import Message from '@/views/message'
import Search from '@/views/search'
import HeaderTitle from '@/components/headerTitle'
import HeaderNav from '@/components/header'
import Tabbar from '@/components/Tabbar'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home',
    meta: {}
  },
  {
    path: '/home',
    components: {
      header: HeaderNav,
      default: Home,
      footer: Tabbar
    },
    meta: {
      isNav: true,
      title: '首页'
    }
  },
  {
    path: '/cart',
    components: {
      header: HeaderTitle,
      default: Cart,
      footer: Tabbar
    },
    meta: {
      isNav: true,
      title: '购物'
    }
  },
  {
    path: '/list',
    component: List,
    meta: {}
  },
  {
    path: '/detail',
    component: Detail,
    meta: {}
  },
  {
    path: '/login',
    component: Login,
    meta: {}
  },
  {
    path: '/category',
    component: Category,
    meta: {}
  },
  {
    path: '/mine',
    components: {
      header: HeaderTitle,
      default: Mine,
      footer: Tabbar
    },
    meta: {
      isNav: true,
      title: '个人中心'
    }
  },
  {
    path: '/message',
    components: {
      header: HeaderTitle,
      default: Message,
      footer: Tabbar
    },
    meta: {
      isNav: true,
      title: '消息中心'
    }
  },
  {
    path: '/search',
    components: {
      header: HeaderTitle,
      default: Search,
      footer: Tabbar
    },
    meta: {
      isNav: true,
      title: '发现'
    }
  }
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
